<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>
    <template id="t1">
      <div>
        {{lastName}} , {{firstName}}
        <hr />
        {{fullName}}
      </div>
    </template>
    <script src="./vue.js"></script>
    <script>
      /*
         计算属性
         1. 定义在computed中的方法，可以将方法名作为属性名在模板中调用，方法的返回值就是属性值 
      */
      const vm = new Vue({
        el: "#app",
        template: "#t1",
        data: {
          firstName: "li",
          lastName: "jack",
        },
        // 计算属性
        computed: {
          fullName() {
            return `${this.lastName} ${this.firstName}`;
          },
        },
      });
    </script>
  </body>
</html>
